#ifndef APITEST_H
#define APITEST_H

#define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEY_UP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)

void TestOpenGL (HINSTANCE hInstance, HINSTANCE hPrevInstance,
				 LPSTR lpCmdLine, int nShowCmd, BOOL Fullscreen)
{
	GraphicsDevice* Renderer = new OpenGLDevice;
	Renderer->Init(hInstance, L"OpenGL Engine Test", 800, 600, 32, Fullscreen);

	while (Renderer->HandleWindowEvents())
	{
		Renderer->BeginRendering();
		Renderer->EndRendering();
		if (KEY_DOWN(VK_ESCAPE))
			break;
	}
}

void TestDirectX (HINSTANCE hInstance, HINSTANCE hPrevInstance,
				  LPSTR lpCmdLine, int nShowCmd, BOOL Fullscreen)
{
	GraphicsDevice* Renderer = new DirectXDevice;
	Renderer->Init(hInstance, L"DirectX Engine Test", 1280, 800, 32, Fullscreen);

	Camera Cam ((D3DDEVICE)Renderer->GetDrawDevice());
	
	Cam.SetCameraPosition(0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 100.0f);
	Cam.SetCameraPerspective(D3DXToRadian(45),
		(float)Renderer->GetScreenWidth()/(float)Renderer->GetScreenHeight(),
		 1.0f, 100.0f);

	DXModel Building1 ((D3DDEVICE)Renderer->GetDrawDevice(), L"Building.x");
	DXModel Building2 ((D3DDEVICE)Renderer->GetDrawDevice(), L"Building3.x");
	DXModel Building3 ((D3DDEVICE)Renderer->GetDrawDevice(), L"Church.x");
	Building1.Rotate(0.0f, ToRad(150), 0.0f);
	Building1.Translate( 12.0f,  1.0f,  15.0f);
	Building2.Scale(0.5f, 0.5f, 0.5f);
	Building2.Translate(-12.0f, -1.0f,  10.0f);
	Building3.Translate( 0.0f, -3.0f, -25.0f);

	while (Renderer->HandleWindowEvents())
	{
		Renderer->BeginRendering();
		Building1.Draw();
		Building2.Draw();
		Building3.Draw();
		Renderer->EndRendering();
		Cam.RotateCamera(0.0f, 0.005f, 0.0f);
		if (KEY_DOWN(VK_ESCAPE))
			break;
	}
}

#endif